cmake_minimum_required(VERSION 3.13)
project(cfgm C CXX)

set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)

set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

set(TARGET_HOST_SYSTEM "unix")

if (TARGET_HOST_SYSTEM MATCHES "unix")
    set(PLATFORM_DEPEND_PATH unix)
endif (TARGET_HOST_SYSTEM MATCHES "unix")

set(PROJECT_SRC
    src/rules.c
    src/cfgm.c
    src/string.c
    src/format.c
    src/types.c
    src/parsers/parser_context.c
    src/parsers/token.c
    src/parsers/tokenizer.c
    src/parsers/cml/lexer.c
    src/parsers/cml/parser.c
    src/parsers/cml/factory.c
    src/parsers/xml/parser.c
    src/parsers/xml/factory.c
    src/${PLATFORM_DEPEND_PATH}/file.c
    )

add_library(${PROJECT_NAME} SHARED ${PROJECT_SRC})

target_include_directories(${PROJECT_NAME} PRIVATE include)
target_link_libraries(${PROJECT_NAME} PUBLIC Threads::Threads)

add_subdirectory(test)
add_subdirectory(doc/cml/cpp)
